package br.ufrj.dcc.manifestacoes.util;

import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import facebook4j.Comment;
import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.Reading;
import facebook4j.ResponseList;
import facebook4j.User;
import facebook4j.auth.AccessToken;
import facebook4j.conf.Configuration;
import facebook4j.conf.ConfigurationBuilder;

public class FacebookUtil {

	public static final String ID_POST = "598152480218764";
	


	public static ResponseList<Comment> getComments(Facebook facebook, String idPost) {
		try {
			
			return facebook.getPhotoComments(idPost,new Reading().limit(1000));
			
		} catch (FacebookException e1) {
			e1.printStackTrace();
			return null;
		}
	}

	public static Facebook getConnection() {
		ConfigurationBuilder confBuilder = new ConfigurationBuilder();
		confBuilder.setOAuthAppId(Constantes.ID);
		confBuilder.setOAuthAppSecret(Constantes.SECRET);
		confBuilder.setOAuthPermissions ("email, publish_stream, read_stream");
		confBuilder.setDebugEnabled(true);
		Configuration configuration = confBuilder.build();
		Facebook facebook = new FacebookFactory(configuration).getInstance();
		facebook.setOAuthAccessToken(new AccessToken(Constantes.TOKEN));
		return facebook;
	}

	public static Integer generoToInt(String genero) {
		if(genero.equals("female")){
			return 1;
		}
		else if(genero.equals("male")){
			return 0;
		}
		return null;
	}
	
	

}
